f = imread('pout.tif');
[M,N]=size(f);
g=zeros(M,N);
f=double(f);
g=double(g);
k1=min(min(f));
k2=max(max(f));
a=k1+50;
b=k2-50;
c=k1-30;
d=k2+20;
for i=1:M
    for j=1:N
        if((f(i,j)>=a)&&((f(i,j))<b))
            g(i,j)=((d-c)/(b-a))*(f(i,j)-a)+c;
        end
        if(f(i,j)<a)
            g(i,j)=c;
        end
        if(f(i,j)>=b)
            g(i,j)=d;
        end
    end
end
figure;
subplot(1,2,1);
imshow(f,[]);
subplot(1,2,2);
imshow(g,[]);
